from django.contrib import admin
from .models import Questionnaire, Question, Answer


@admin.register(Questionnaire)
class QuestionnaireAdmin(admin.ModelAdmin):
    list_display = ('id', 'questionnaire_name', 'questionnaire_description', 'questionnaire_status', 'create_time')
    list_display_links = ('id', 'questionnaire_name')
    list_editable = ('questionnaire_description', 'questionnaire_status')
    list_filter = ('questionnaire_status', 'create_time')
    search_fields = ('questionnaire_name', 'questionnaire_description')
    date_hierarchy = 'create_time'
    ordering = ('-create_time',)


@admin.register(Question)
class QuestionAdmin(admin.ModelAdmin):
    list_display = ('id', 'questionnaire', 'question_text', 'required_question')
    list_display_links = ('id', 'question_text')
    list_editable = ('required_question',)
    list_filter = ('questionnaire',)
    search_fields = ('question_text',)
    ordering = ('-id',)


@admin.register(Answer)
class AnswerAdmin(admin.ModelAdmin):
    list_display = ('id', 'question', 'answer_text', 'create_time')
    list_display_links = ('id', 'answer_text')
    list_filter = ('question',)
    search_fields = ('answer_text',)
    ordering = ('-id',)